﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Business;

namespace ServicesDirectory.UserControl
{
    public partial class DetailGovernment : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["GovId"] != null)

                GetGovOfficeRegionById(Request.QueryString["GovId"]);

        }

        private void GetGovOfficeRegionById(string govOfficeRegionId)
        {
            var govOfficeRegionDetail = GovOfficeRegionBusiness.Instance.GetGovOfficeRegionById(govOfficeRegionId);
            var listCounty = CountyBusiness.Instance.GetByGovOfficeRegion(govOfficeRegionId);
            txtGovName.Text = govOfficeRegionDetail.GovOfficeRegionName;
            txtDescription.Text = govOfficeRegionDetail.Description;
            foreach (var county in listCounty)
            {
                txtCountyList.Text += county.CountyName + "\n";
            }
            txtGovName.ReadOnly = true;
            txtDescription.ReadOnly = true;
            txtCountyList.ReadOnly = true;
        }

        protected void cmdBack_Click(object sender, EventArgs e)
        {
            Response.Redirect("ListGovOfficeRegion.aspx");
        }
    }
}